home *** CD-ROM | disk | FTP | other *** search
/ Mac OS 9 Serial Number Archive / SN Archive 2023.11.04.toast / Cracking Texts / Macsbug etc.txt < prev    next >
Encoding:
Text File  |  2010-08-04  |  42.9 KB  |  739 lines  |  [TEXT/R*ch]

  1.  
  2. fourteen                 @         14        @                fourteen
  3.                          @    hex and such   @
  4. fourteen                 @       ProZaq      @                fourteen
  5.  
  6.  
  7.  
  8. Are you a "newbie"?  As long as you're interested in not only computers but also in
  9. what's making computers work the way they do, then you'll definitely need to learn
  10. and master the meaning of a couple of basic expressions/ terms/ concepts.  Take, for
  11. example, the hexadecimal number system; it doesn't matter if you want to learn the
  12. basics of programing or if you want to write programs for Macs or PC's or you just
  13. wanna cheat on some computer games; you have to learn and master it in order to be able
  14. to "exploit" it.  And as you learn more you will notice that all these concepts are
  15. interrelated and one can be manipulated to change the other.
  16.  
  17. In this file I shall try to explain the following topics: binary and hexadecimal numbers,
  18. bytes/words/longs, ASCII characters, strings, HexEditors, the hardware components of a
  19. computer, and debuggers.  If you find that you are not familiar with an expression, then
  20. take a look in the "The Computer's Hardware Components" chapter.
  21.  
  22.  
  23. --==< Binary, Decimal, and Hexadecimal Numbers >==--
  24.  
  25. Oh boy!  Where do I start?  Well, at the very, very, very beginning...
  26. If I remember my IT classes well, the whole fame about binary numbers and calculations
  27. with binary numbers goes to an English fellow named George Boole.  He developed amongst
  28. others Boolian Algebra.  Remember all those horrible hours you had to spend in algebra
  29. class learning formulas like: a(b+c) = a*b + a*c?  Well you have him to thank for it.
  30. e also developed a type of logic where he used ones and zeros to represent the logical
  31. flow of an operation, which is the kind of logic that every personal computer chip uses
  32. today.
  33.  
  34. You know how everyone is always saying  that computers are all about ones and zeros?
  35. Well that's because everything in computers narrows down to being a one or a zero (an
  36. electronic current or the lack of it).
  37.  
  38. But what on earth is the binary number system?  Well, let's try to define the decimal
  39. number system first (the one we use in every day mathematics) since we're more familiar
  40. with it.
  41.  
  42. The decimal number system is based on the number 10.  Twas the name "Decimal"; which
  43. means "tenth" in Latin (doesn't "mal" mean "multiply" in German?).  You have the numbers
  44. zero through nine.  When you start counting from zero up, you hit nine.  And what happens
  45. when you hit ten?  You reset the value of the rightmost column (set it to zero), and
  46. carry a one into the next column.   At one hundred you reset the two rightmost columns
  47. and carry a one into the next one. And so on.  So as you notice you carry numbers at the
  48. powers of ten.  Like 10^1 =10 (^ means raised to the power), 10^2 = 100, 10^3 = 1000, 10^4
  49. = 10 000, 10^5 = 100 000, 10^6 =1 000 000 etc.
  50.  
  51. Let's break the number "9876" into columns representing the numbers at which the carrying
  52. occurs.  The "thousands", "hundreds", "tens", and "ones" column.
  53.  
  54. | Thousands  |  Hundreds  |    Tens    |    Ones    |
  55. |   (10^4)   |   (10^3)   |   (10^2)   |   (10^1)   |
  56. |      9     |      8     |      7     |      6     |
  57.  
  58. As you might have noticed, in order to get the number nine thousand eight hundred and
  59. seventy six you multiply the value of each column with the appropriate multiple of ten
  60. then add the values together (9*10^4 + 8*10^3 + 7*10^2 + 6*10^1).
  61.  
  62. In the binary number system we only have two numbers to work with instead of ten as we
  63. had in decimal.  One and zero.  So this means, that instead of carrying numbers at the
  64. powers of ten we carry numbers at the powers of two; namely: 2^1 = 2, 2^2 = 4, 2^3 = 8,
  65. 2^4 = 16, 2^5 = 32, 2^6 = 64, 2^7 = 126 and 2^8 = 256.
  66.  
  67. When dealing with binary a lot of times the value of all eight columns of numbers are
  68. shown even if it is zero.  Makes the calculations easier.  For example, one in binary has
  69. the value 1 but can also be written as 00000001.
  70.  
  71. Here is a little chart showing the numbers one to sixteen in binary:
  72.  
  73. Value of column:
  74.  126 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | = value of each column added up
  75.   0     0    0    0   0   0   0   0   = 0
  76.   0     0    0    0   0   0   0   1   = 1
  77.   0     0    0    0   0   0   1   0   = 2
  78.   0     0    0    0   0   0   1   1   = 3
  79.   0     0    0    0   0   1   0   0   = 4
  80.   0     0    0    0   0   1   0   1   = 5
  81.   0     0    0    0   0   1   1   0   = 6
  82.   0     0    0    0   0   1   1   1   = 7
  83.   0     0    0    0   1   0   0   0   = 8
  84.   0     0    0    0   1   0   0   1   = 9
  85.   0     0    0    0   1   0   1   0   = 10
  86.   0     0    0    0   1   0   1   1   = 11
  87.   0     0    0    0   1   1   0   0   = 12
  88.   0     0    0    0   1   1   0   1   = 13
  89.   0     0    0    0   1   1   1   0   = 14
  90.   0     0    0    0   1   1   1   1   = 15
  91.   0     0    0    1   0   0   0   0   = 16
  92.  
  93. Here's an other approach in trying to explain how binary works.  Try adding up the values
  94. of the columns where there is a one.  In ten for example (00001010) there is a one in the
  95. two's and the eight's column.  Thus when these values are added together (two plus eight)
  96. we get ten.  The same goes for fifteen, there's a one in each column so, eight plus four,
  97. plus two, plus one equals fifteen.
  98.  
  99. OK, now we've reached the hexadecimal numbers.  Well, for these suckers we carry at powers
  100. of sixteen.  With other words we count from zero to fifteen before reseting the first
  101. column and increasing the next.  The slight problem of only having ten numbers in our
  102. everyday number system is compensated by using six alphabetical letters to represent the
  103. numbers ten through fifteen.  Thus the numbers used in the hexadecimal number system have
  104. the following notation:
  105. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
  106.  
  107. Once fifteen is reached, the next number (as always) is represented by reseting the first
  108. column and increasing the next.  Meaning that sixteen in hex is "10".
  109.  
  110. If you have managed to get this far you've done a good job.  And if you still have
  111. difficulties understanding what the different number systems are all about then I'll let
  112. you in on a big secret.  Only a very few people convert between number systems in their
  113. head. Most of us mortals rely on something called the "Scientific calculator".   This
  114. makes life a lot simpler!  I always use a calculator simply because it's just so much
  115. faster.  I believe that if you know the principles behind the different number systems
  116. and you have access to a calculator that converts between these then you're set.
  117.  
  118. So now you know what different number systems are.  But when it comes to writing them down
  119. some difficulties may arise.  It's obviously easy to distinguish numbers represented in
  120. binary.  Just to be on the safe side, however, it's a convention to put a "%" sign in
  121. front of binary numbers.  On the other hand "123" can be a number represented in both hex
  122. and decimal form.  If it's a decimal number it's simply one hundred twenty three.  But if
  123. it's a hexadecimal number then it has the decimal value of 291, two hundred ninety one.
  124. Big difference there!  So how do you distinguish between hex and decimal numbers?  Well
  125. the most common way is to represent hex numbers by putting a dollar sign, "$" in front of
  126. the number. In the programing language C you represent decimal numbers using the "0x"
  127. prefix.  In assembly language it is common practice to use the "#" sign when representing
  128. decimal numbers.  I tend to be very lazy so when I want to represent decimal numbers I
  129. just don't bother using any signs, but for hex numbers I always use the "$" sign.  For
  130. example: #12345 (decimal) is $3039 (hexadecimal);  and $ABCDEF (hexadecimal) is 11259375
  131. (still decimal if no sign is used).  Through the course of this file I will use this
  132. method of notation.  I might, however, refer to hexadecimal numbers without the $ sign
  133. if I think that it's obvious what I mean.
  134.  
  135.  
  136. --==< Bytes, words, and longs >==--
  137.  
  138. Now that you know what hex is, there is a need to discuss the length of a number.  The
  139. length of numbers have a large part when it comes to writing programs.  By using numbers
  140. with different lengths the programmer can manipulate data much more easily.  Another
  141. benefit of numbers with different lengths is that a small numbers will occupy a small
  142. place in the memory instead of occupying an unnecessarily large one.  This is not much of
  143. a problem now with the increase of of both RAM and HardDisk sizes, but back in the days
  144. of C-64's and before, when programmers only had so much RAM to work with, it was very
  145. important wether a number took up 1 or 4 bytes.
  146.  
  147. Anyway, in assembly language for the 68k Macintosh processors we talk about bytes, words
  148. and longs.  A byte is two digits long and is between 00 and FF (0 to 255 in dec).  A word
  149. is 4 digits long and is between 00 00 and FF FF (0 to 65535 in dec).  Finally a long is
  150. made up of 8 digits and is between 00 00 00 00 and FF FF FF FF (0 to 4294967295 dec).
  151.  
  152. With other words:
  153.  
  154. byte:      $00              - $FF                   #0 - #255
  155. word:      $00 00           - $FF FF                #0 - #65535
  156. long:      $00 00 00 00     - $FF FF FF FF          #0 - #4294967295
  157.  
  158. As you can see a byte takes up one fourth of the memory a long does.  This principle will
  159. be discussed further in the chapter dealing with HexEditors.  I think it might be a good
  160. thing for you to learn how many digits a byte, a word and a long has.  I will use these
  161. expressions later on.  I chose to use these expressions (and not including floats and
  162. doubles) because I feel that even an experienced person can get far with only these three
  163. length-notations.
  164.  
  165. For those interested, the programing language C uses the following expressions to refer
  166. to the length of numbers:
  167.  
  168. char                c = 'A';  // 1-byte long by definition (in C++).
  169. short int           si= 1;    // minimum range +/-32767.
  170. short               s = 2;    // short same as short int.
  171. int                 i = 3;    // minimum range +/-32767.
  172. long int            li= 4;    // minimum range +/-2147483647.
  173. long                l = 5;    // long same as long int.
  174. float               f = 10.1; // min 6 digits (decimal) precision.
  175. double              d = 11.2; // min 10 digits (decimal) precision.
  176. long double         ld= 12.3;
  177.  
  178. unsigned char       uc;       // unsigned integers can only store
  179. unsigned short int  usi;      // positive numbers.
  180. unsigned int        ui;
  181. unsigned long int   uli;
  182.  
  183. signed char         sc;       // signed integers can store positive
  184. signed short int    ssi;      // or negative numbers.
  185. signed int          si2;
  186. signed long int     sli;
  187. (Information taken from "C Reference Card" by Argus Software Engineering)
  188.  
  189.  
  190. --==< ASCII Characters >==--
  191.  
  192. With the arrival of networks reaching from one country to the other arose the problem of
  193. character mapping.  When you push the letter "a" on your keyboard, the hardware components
  194. of the computer send a number value to the processor which represents the letter "a".  But
  195. how on earth would a computer in Yugoslavia, configured to deal with the Yugoslavian
  196. alphabet, be able to interpret letter "ä" which is fairly common in the Swedish language.
  197. To eliminate the problem a new standard for keyboards, the American Standard Code for
  198. Information Interchange (ASCII) was adopted in most places.  What this means is that (in
  199. theory at least) all alphabetical characters will appear the same way no matter where you
  200. are in the world. Unfortunately this only works in theory, since different keyboards have
  201. different mapping of different keys and have different ways of showing different letters
  202. etc...  The good news is that just like you didn't have to know how to convert hex numbers
  203. in your head, it's enough that you know that ASCII refers to the numerical values of the
  204. different characters on your keyboard that the computer can interpret as such.
  205.  
  206. Now you know that when you push a key on the keyboard, the corresponding number value is
  207. sent to the processor (well in reality it's interpreted by the OS and sent to the active
  208. application).  So, what is this number value?  Well, every character on the keyboard is
  209. represented by a different number.  For example the English lowercase alphabetical
  210. characters range from $61 to $7A (a-z).  Notice that when it comes to computers there's a
  211. define difference between lowercase and uppercase letters.  Thus the uppercase English
  212. letters are represented by the numbers $41 to $5A (A-Z).
  213.  
  214. It is important to realize that every ASCII character (every character on the keyboard)
  215. can be represented by a number that's the size of a byte.  Meaning a number between 1-255,
  216. $1-FF. Thus the current standard of keyboard maps can only handle 255 characters.
  217.  
  218. But that's of no real importance either.  The most common ASCII characters and their
  219. values in both hex and decimal form are available in the included file "ASCII.txt"
  220.  
  221. Now then, we know that ASCII characters are represented by numbers.  For example the
  222. capital letter "A" is represented by 65 ($41).  "B" is 66 ($42) and "C" is 67 ($43).  So
  223. the letters "ABC" could be represented by the ASCII values 65 66 67 (or in hex 41 42 43).
  224. And this brings us to our next topic, strings.
  225.  
  226.  
  227. --==< Strings >==--
  228.  
  229. The expression "string" refers to a sequence of keyboard characters.  For example "Hello
  230. world!" would be a string.  Notice that the computer doesn't care about the space between
  231. the two words, it looks upon the sentence as only one string of characters.  This leads to
  232. the problem of representing strings.  Imagine how a string would look like in the
  233. computer's point of view.  It would be a sequence of numbers stored somewhere in the
  234. memory.  And unless you inform the computer how to interpret the beginning or end of the
  235. string, it will not know where the string ends.
  236.  
  237. There are currently two standard ways of representing strings.  The C way and the Pascal
  238. way. I'll start with the C way, it's easier.  Basically after the last character in the
  239. string there is a zero-byte.  This means that a value of zero marks  the end of the string.
  240. For example:
  241.  
  242.   H     E     L     L     O     _     W     O     R     L     D     !    •
  243.  72    69    76    76    79    95    87    79    82    76    68    33   00
  244. $48   $45   $4c   $4c   $4f   $5f   $57   $4f   $52   $4c   $44   $21  $00
  245.  
  246. Keeping in mind that the size of an ASCII character is that of a byte (max 255)  we notice
  247. that using the C method the length of the string is actual increased by one byte; the
  248. zero-byte on the end.  When a program is in need of using the above string, it needs to
  249. know the memory address of the first character, and it knows that it has hit the end of
  250. the string when the value of the character is zero.
  251.  
  252. The Pascal method is a bit different.  It stores the number of characters in the string
  253. as the first byte.  The example above would be portrayed like this in Pascal notation:
  254.  
  255.      •     H     E     L     L     O     _     W     O     R     L     D     !
  256.     12    72    69    76    76    79    95    87    79    82    76    68    33
  257.    $0c   $48   $45   $4c   $4c   $4f   $5f   $57   $4f   $52   $4c   $44   $21
  258.  
  259. As you might have noticed there are 12 characters in the string (including the "_" and
  260. the "!" signs).  So using the Pascal method, the program would read the first byte of the
  261. string and thus determine the lenght of it.
  262.  
  263. This whole concept will be developed further in the next chapter.
  264.  
  265.  
  266. --==< Hex Editors >==--
  267.  
  268. NOTICE: When dealing with hex editors you are going to be changing real files on your
  269. computer.  By changing just one byte in a file you can corrupt it to the extent that it
  270. will not be usable any more!  So always make sure that you are working on a BACKUP of the
  271. file. The easiest thing to do is to create a folder where you copy all the files that you
  272. want to change with the HexEditor.
  273.  
  274. Remember how all data processed by the computer is made up of a one or a zero?  Well, the
  275. same principle holds true for files stored on the hard disk, on a floppy disk, on a CD-ROM,
  276. or on any other storage media.  But because hexadecimal numbers are easier to deal with
  277. than binary numbers, we have programs that can read the content of any storage media as
  278. pure hexadecimal data.  These programs are called HexEditors.  Using the above idea, any
  279. file containing data that is stored on a media can be opened and it's contents will be
  280. represented as hexadecimal numbers.  And it does not matter whether the file is an
  281. application program or just a simple text file, since ALL files are at their "lowest
  282. level" made up of binary numbers and can thus be viewed by a HexEditor.
  283.  
  284. The first thing you have to do is to find yourself a HexEditing program.  It doesn't matter
  285. which computer platform you have.  HexEditors exists for PC's, Mac's, Unix's, even C-64's
  286. Once you've found a HexEditor open up any backup file with the program.  I have a Mac and I
  287. use HexEdit 1.0.7, a freeware program by Jim Bumgardner.  If I open an application file I
  288. get something like this:
  289.  
  290. (See the picture "HexEdit.jpg")
  291.  
  292. Please note that you WILL get something completely different, since the chances of us
  293. opening the same file is very slim, and different HexEditors present the information in
  294. different  ways.
  295.  
  296. Let me explain the above picture.  To the left you have the Offset column.  "Offset"
  297. refers to the distance of a data from the first byte in the file.  Since the offset here
  298. starts at zero we know that we are dealing with the beginning of the file.  Also notice
  299. that the offsets are displayed as hex values.  A good HexEditor should be able to display
  300. the offset as decimal numbers as well.
  301.  
  302. In the middle you have the Hex column.  This is where all the hexadecimal data can be
  303. found. If you converted all these numbers to binary, you'd have a representation of the
  304. binary information of the file as you would find it on the Hard Drive.
  305.  
  306. Finally on the right side is the ASCII column.  This is an ASCII representation of the Hex
  307. values.  This means that each hex number is looked up on an ASCII table and it's ASCII
  308. value is displayed in this column.
  309.  
  310. OK, now what?  Well, as an example I'll describe the use of HexEditors as a way to cheat
  311. on computer games.
  312.  
  313. Off course you can not use a HexEditor to cheat on a game while you are playing it.  Those
  314. situations will be dealt with in the next chapter.  What you can do with a HexEditor,
  315. however, is to change saved games.  I mean, think about it.  What is the program actually
  316. doing when it is saving a game?  It saves all the data about the game to a file.  Like
  317. where you are positioned on the map, what items you carry, how many monsters are gonna
  318. attack you etc...  In this example I will use Realmz, a shareware game for the MacOS.
  319.  
  320. The first thing you have to do is to find where on the HardDrive the game saves it's
  321. files. Some games allow you to save wherever you want, while others will only allow you
  322. to save into a certain set of game folders (usually 1-10 or something like that).  So
  323. search through the game's folders (directories as they are also called), and look for a
  324. file that has the same name as your saved game.
  325.  
  326. The next step is to find the document in which the game stores the information you want
  327. to change.  For example Realmz is a Dungeons & Dragons game for the Mac where you can
  328. create your own characters.  The attributes of the characters, such as it's strength or
  329. stamina,  are saved in a file that has the same name as the character.
  330.  
  331. Let us presume that I have a character called Pro.  His attributes are stored in the file
  332. called "Pro".  I want to change my character's strength.  I want to make him stronger so
  333. that he can cause more damage with each hit.  The first thing I would do is to run the
  334. game and see how strong he is at that particular time.  This will be the value that the
  335. game stores in the "Pro" file.  He has a strength  of 105.  So I convert this number to
  336. hex, which gives me $69. And then I set out to look for the hex byte $69 in the saved file.
  337. To make things easier I look for the hex word "00 69" since the possibility of the string
  338. "00 69" appearing several times in the file is smaller than that of the string "69". (Read
  339. "Note on HexEditors and numbers" for more information regarding this.)  When I've found
  340. this value I change it to whatever I want it to be and then I save my work.
  341.  
  342. The problem might arise that "00 69" appears in more than one places in the file.  The
  343. easiest (and most dangerous way) is to change all the values to the value you want.  By
  344. doing this, however, you might have changed values which are very important to the program
  345. and might cause it to freeze.  By using a trial end error method you can try to change a
  346. different value every time and see if the value you changed was the correct one.  The most
  347. effective method, however, is to look at "00 69" in a context.  Meaning, look at the other
  348. numbers around it. For instance, if you recognize the number after "00 69" as the movement
  349. points of the character then there's a good chance that you're on the right track.
  350.  
  351. Note for Macintosh users:  The MacOS divides up a file into two parts, the data fork and
  352. the resource fork.  Without getting too much into programing, here's what the purpose of
  353. these two forks are.  The resource fork should contain information such as how a window
  354. looks like, where it is located, how the menus look like etc.  With other words
  355. information used by the Operating System.  The data fork should be used to store the
  356. information used by the user's. For example, in a word processor file the resource fork
  357. might contain information regarding the size of the window, while the data fork might
  358. contain the actual text written by the user. However, the programmer is not obliged to
  359. follow these criterias.  They are only suggestions made by Apple.  So, when you are
  360. looking at a file with a HexEditor on a Mac, be sure to check both forks of the file for
  361. the information you are looking for.
  362.  
  363.  
  364. --==< Note On HexEditors And Numbers >==--
  365.  
  366. I find it appropriate to give a bit of a revision of numbers and strings.
  367. To use the example from above, let's presume that my character had the strength of $69.
  368. What we don't know is how the program stores this number.  It might store it as a byte, a
  369. word, or a long (see chapter about bytes, words and longs for more info about this).
  370. Using common sense, if my character has a strength of $69 and is considered very very
  371. strong than the program will probably save the value as a byte or a word.  It's completely
  372. useless for it to store it as a long (although it might happen).  If, however, we regard
  373. the characters experience point, its obvious that it is a lot larger than the range of a
  374. word, so it HAS to be stored in a long (or something larger).   So instead of searching
  375. for "ABCDE" you can search for "00 0A BC DE" which should narrow down the number of
  376. occurrences of that number.
  377.  
  378. Another thing that needs to be discussed is that the length of a number has to be even.
  379. A programmer deals with blocks (units) of memory.  The program then reserves these blocks
  380. once it's launched.  The smallest block a programmer deals with is a byte.  This means
  381. that no matter how much the programmer wants it, he/she can never store the number "1"
  382. just like that. If it is to be stored in the memory it will be stored as "01".  However,
  383. if the programmer assigned the number to be a word it will be stored as "00 01".  And if
  384. it was assigned to be a long it will be stored as "00 00 00 01".  The computer doesn't
  385. care what number is stored in the variable.  It only cares about the length of the
  386. variable.  Thus if the computer stores three longs with the values $1, $22 and $333
  387. respectively then it will look like this once you open the file with a HexEditor:
  388.  
  389. 00 00 00 01 00 00 00 22 00 00 03 33
  390.  
  391. Lets say you want to change the $333 part to $433.  A good HexEditor might allow you to
  392. search for "333" but remember that the smallest unit is a byte.  When you are changing
  393. "00 00 03 33" to "00 00 04 33" it's pointless to change all 8 digits.  It's enough if you
  394. change the 3'rd byte ("03" to "04").  Notice, however, that you can't just change 3 to 4.
  395. You have to change "03" to "04".  A good HexEditor should actually not allow you to change
  396. one digit at a time. It should require you to change one byte, 2 digits, at a time. If you
  397. are confused then re-read this chapter, and the previous chapter dealing with lengths of
  398. numbers.  This is important stuff, and it's very important that you know it well!
  399.  
  400.  
  401. --==< The Computer's Hardware Components >==--
  402.  
  403. Now we have covered a lot of track.  You should know what the different number systems are,
  404. you should have an understanding of different programing expressions and you should know
  405. how to use a HexEditor.  In order to understand how a Debugger works, however, we need to
  406. dive into the hardware components of a computer.  Do not worry, I will keep it simple.  I
  407. will only talk about the most important parts of the computer.  As a matter of fact you
  408. will most likely recognize and already know the function of some of these components.
  409.  
  410. - The Motherboard - This is that green board within your computer covered with circuits
  411. where all the hardware is placed.  Everything from the diskdrive to the microphone is
  412. somehow connected to the Motherboard.
  413. - Memory - The part of the computer where data is stored.
  414. - RAM (Random Access Memory) - This is the temporary storage facility of the computer.
  415. It is loaded full with information when you turn on the computer and it is emptied when
  416. you turn your computer off.
  417. - PRAM (Parameter RAM) - Very much like ordinary RAM with the exception that there is a
  418. special battery in the computer providing the PRAM with enough electricity to keep the
  419. information in it even when the rest of the computer is turned off.
  420. - ROM (Read Only Memory) - This is a storage unit where information can only be read from.
  421. With other words the computer can read anything in the ROM but it can not change anything
  422. there.  Thus the ROM usually stores all the information the computer needs to be able to
  423. start when you press the "On" button.  When you think about it, a compact disk (CD) is
  424. also a read-only unit.  The computer can read the information on it, but it can't store
  425. stuff on it. Thus the name CD-ROM.
  426. - Storage Media - For example, the HardDrive, a floppy disk, a Zip disk, etc.  These
  427. are accessories to the computer on which information is stored "indefinitely".  That is
  428. "indefinitely" in the sense that the information will still be there, even when the
  429. computer off.  This does, however, not keep the computer from replacing the information on
  430. the media. So it can freely read from it and write to it.  It can even replace existing
  431. data with new data.
  432. - The Processor - This is the brain of the computer.  All data is sent to be calculated in
  433. the processor.
  434. - Registers - These are blocks of memory within the processor where data is stored for a
  435. brief period of time, waiting to be processed.
  436. - Busses - Circuits, on the motherboard, where the information travels from one component
  437. of the motherboard to the other.
  438. - The Sound Card - This is like a small mother board with it's own processor, busses and
  439. registers capable of converting binary information to sound waves.
  440. - The Graphics Card - Same as the sound card except it displays information as the
  441. graphics on the monitor.
  442.  
  443. And that's all you need to know for now.
  444.  
  445.  
  446. --==< Debuggers >==--
  447.  
  448. I gave this whole chapter a lot of thought and decided on the following.  I will only give a
  449. general description of a debugger, and some theoretical uses for it.  There are a lot of
  450. different debuggers out there, for all computer platforms.  I use a Macalong with Apple's
  451. own free debugger called MacsBug.  For those interested I have included a file called
  452. "MacsBug".  I wrote this file a while back and it is not designed to be read by beginners.
  453. However, some people might find it handy.  There are a quite a lot of other files dealing
  454. with MacsBug that might be a lot more useful.  So if you are really interested, read a few
  455. of those as well!
  456.  
  457. A debugger is a program that allows you to take control of the complete computer.  This is
  458. done, by "stoping" the processor.  When you activate a debugger, it stops the processor
  459. from executing any commands of the program that is running at the moment.  The whole
  460. concept of a debugger is to help software developers look for mistakes in their programs or
  461. to see if it executes in a proper way.
  462.  
  463. As you may know, when a program is launched, the Operating System loads the program from
  464. the HardDrive to the RAM.  This is done because the RAM is a lot faster than the HardDrive
  465. and most other storage medias.  Then the processor jumps to the part of the RAM where the
  466. code of the program is stored, and it starts executing each of the commands.  So, when the
  467. debugger is started the processor stops executing these commands.  It then allows the user
  468. to check the values of the certain hardware components.  This way the user can detect any
  469. mistakes in the program or just check the current state of the hardware components.  The
  470. user can even step through the code of the program.  This means that they can look at each
  471. command that makes up the program and see what it does.  As I said before, debuggers are
  472. largely used by programmers trying to figure out why their program won't work properly.
  473.  
  474. For you, the main advantage of a debugger will be that it allows you to change the data in
  475. most hardware components, including the RAM.  Since the program is loaded into the RAM when
  476. launched, and it does all the calculations in the RAM all the data/variables/information it
  477. may use will most likely be stored somewhere in the RAM.  Thus the debugger can be used to
  478. change any of these.
  479.  
  480. Since this file has had a general undertone of being an aid for cheating on computer games
  481. I decided to include a way to use MacsBug to cheat on games while you are actually playing
  482. them. I will first summarize the theory and then go into the specifics.  In order for you
  483. to be able to follow it through you will have to know at least the basic commands and
  484. functions of MacsBug.  If you are using a different debugger, then the theory will most
  485. likely be the same but the commands will be different.
  486.  
  487. WARNING:  When you are changing memory contents or changing anything in a debugger for
  488. that matter, you CAN cause very large damages to your computer!  The incorrect use of a
  489. debugger can cause the computer to freeze and cause information to be lost!  Several other damages
  490. can also occur.  Thus I advise you to become familiar with your debugger before you
  491. attempt to change anything with it.  Read any related files, read the manuals and do some
  492. minor experimenting before you try to change stuff directly in the memory!
  493.  
  494. So first, the theory.  I launch the game as a start.  By opening up any saved games, I
  495. force the game to load anything it might have saved on the HardDrive (and that is of use
  496. to me) to the RAM.  Then I stop the game by starting the debugger, I find where in the
  497. RAM the game is stored, I find the information I want to change and then I change it.
  498.  
  499. OK, and now for practice:
  500.  
  501. Here's the scenario:  I'm playing Heroes of Might & Magic II and I want more creatures in
  502. my armies.  I open up the hero's preference window and see that my hero has 25 Minotaurs,
  503. 53 Dwarfs, 32 Griffins, 9 Skeletons and 2 Dragons.  Thus I know that the computer keeps
  504. track of how many creatures I have and that means that the number of creatures must be
  505. stored somewhere in the RAM.
  506.  
  507. The first thing I have to do is to find out where in the RAM the game is located.  The
  508. first step is to drop into MB (this is done by holding down the apple key and pressing
  509. the power button on the keyboard).
  510.  
  511. The second step is to issue the "hz" (heap zone) command that lists all the currently
  512. active applications and their locations in the RAM.  I got this:
  513.  
  514.  Heap zones
  515.   #1  Mod        7206K  00002800 to 0070C34F  SysZone^
  516.   #2  Mod           6K    00008D60 to 0000A88F  ROM read-only zone
  517.   #3  Mod          48K    001301F0 to 0013C1EF
  518.   #4  Mod         128K    004475B0 to 004675AF
  519.   #5  Mod       29560K  0070C350 to 023EA69F  Process Manager zone
  520.   #6  Mod        9737K    010A6830 to 01A28EFF  “Heroes II”     ApplZone^  TheZone^  Targ
  521.  
  522. As you can see Heroes II starts at memory location 010A6830 and ends at 01A28EFF (all in
  523. hex of course).
  524.  
  525. The next step is to use the "find" command and find the number of creatures that make up
  526. my army.  See, it is very likely that a game stores relevant data close to each other. So
  527. I presume that the program stores the number of creatures I have, in a specific block of
  528. memory in the RAM.  If I can find this block of memory, I will be able to change it's
  529. content, thus changing the number of creatures.   In some ways it's like finding
  530. information with a HexEditor.  Except you're looking for data in the RAM and not in a
  531. file.
  532.  
  533. In order to be able to use the "find" command I have to be able tell the following things:
  534. the start of the memory address, how many bytes the debuggers should search for, and what
  535. to search for.  Unfortunately I don't have all the criteria.  I have to find out how many
  536. bytes Heroes II occupies.  This can easily be done by subtracting $010A6830 from
  537. $01A28EFF. This subtraction gives me $009826CF.  If you want you can do this calculation
  538. directly in MB, just type "01A28EFF-009826CF".  Now I have all the stuff I need to use
  539. the find command.
  540.  
  541. In this example I issue "f 010A6830 009826CF 00190035"
  542.  
  543. The "f" stands for "find". This tells MB to use the find command.
  544. "010A6830" is the address of the memory where Heroes II starts.
  545. "009826CF" stands for the number bytes Heroes II occupies in the memory. It tells MB the
  546. number of bytes I want to search for, from the initial address.
  547. "00190035" stands for 25 Minotaurs and 53 Dwarfs.  #25=$19 and #53=$35.  Since I've done
  548. this before I know that Heroes II stores the the number of creatures in word sized blocks
  549. of memory.  If I didn't know that I would have had to search for "0019" first (or "19")
  550. and look at it in it's context.  When I issued the find command I got this:
  551.  
  552. Searching for 00190035 from 010A6830 to 01A28EFE
  553.   0118EE3E  0019 0035 0020 0009  0002 0000 0003 0100  •••5•••••••••••
  554.  
  555. The first hex long represents an address in the memory.  The following four longs (16
  556. bytes) are the values of the data contained in the RAM starting from that address.  The
  557. following 16 characters are the ASCII representations of these values.
  558.  
  559. Now, if I convert the first five words to decimal numbers I get: 25, 53, 32, 9 and 2.
  560. That's a perfect match of the number of creature I have in my army.  Thus there is a
  561. fairly good chance that HeroesII keeps track of my army starting at address 0118EE3E.
  562. When you are doing something like this on your own and you don't think that this is the
  563. location of the memory that you are looking for, you can continue searching by hitting
  564. return until you get a message saying that it could not be found.
  565.  
  566. Then comes the dangerous part, I have to change the value in the memory.  I issue the
  567. following command, "sw 0118EE3E 00ff" (sw stands for set word).  This changed the word at
  568. the memory address 0118EE3E from "0019" to "00ff".  If I now issue the "dm 0118EE3E"
  569. command (dm stands for display memory) I see that the value at address 0118EE3E has
  570. changed to:
  571.  
  572.   0118EE3E  00FF 0035 0020 0009  0002 0000 0003 0100  •••5•••••••••••
  573.  
  574. So I return to the game by issuing the "g" command.  Apparently nothing has changed.  But
  575. if I close the preferences window and force the game to actually check how many Minotaurs
  576. my army has (by checking the variable stored in the RAM), then I can see that the game in
  577. fact thinks that I have 255 Minotaurs!  Cheat accomplished.  Now I just have to repeat the
  578. above procedures for all the other creatures.
  579.  
  580. NOTE: when you are changing the contents of the memory, make sure that you use the
  581. appropriate addresses, meaning the ones you get when you issue "hz" and the find command.
  582. Do NOT use the memory addresses I used!  They are purely examples and WILL NOT work on
  583. your computer!
  584.  
  585.  
  586.  
  587. --==< End Notes >==--
  588.  
  589. In conclusion I hope to have given an insight to how different principles of computer
  590. technology work.  I'd like to point out to some more advanced readers that I am aware of
  591. the fact that I have generalized and simplified some concepts.  I did this only when I
  592. felt that the theory was more important than a detailed explanation.  I also hope to have
  593. made some of you interested in learning about programing and more advanced topics of IT
  594. and computer technology.  If you have any questions or comments you can reach me at
  595. prozaq@usa.net.
  596.  
  597. Good luck
  598.  
  599. ProZaq
  600. 1999.12.31
  601.  
  602. Werd to mSEC, and everyone else who's ever helped me out!  It's people like you who make
  603. it worthwhile!
  604.  
  605.  
  606.  
  607.  
  608.  
  609. The most common ASCII characters (to be viewd in Monaco)
  610.  
  611.  32 ' '  $20     33 '!'  $21     34 '"'  $22     35 '#'  $23     36 '$'  $24
  612.  37 '%'  $25     38 '&'  $26     39 '''  $27     40 '('  $28     41 ')'  $29
  613.  42 '*'  $2A     43 '+'  $2B     44 ','  $2C     45 '-'  $2D     46 '.'  $2E
  614.  47 '/'  $2F     48 '0'  $30     49 '1'  $31     50 '2'  $32     51 '3'  $33
  615.  52 '4'  $34     53 '5'  $35     54 '6'  $36     55 '7'  $37     56 '8'  $38
  616.  57 '9'  $39     58 ':'  $3A     59 ';'  $3B     60 '<'  $3C     61 '='  $3D
  617.  62 '>'  $3E     63 '?'  $3F     64 '@'  $40     65 'A'  $41     66 'B'  $42
  618.  67 'C'  $43     68 'D'  $44     69 'E'  $45     70 'F'  $46     71 'G'  $47
  619.  72 'H'  $48     73 'I'  $49     74 'J'  $4A     75 'K'  $4B     76 'L'  $4C
  620.  77 'M'  $4D     78 'N'  $4E     79 'O'  $4F     80 'P'  $50     81 'Q'  $51
  621.  82 'R'  $52     83 'S'  $53     84 'T'  $54     85 'U'  $55     86 'V'  $56
  622.  87 'W'  $57     88 'X'  $58     89 'Y'  $59     90 'Z'  $5A     91 '['  $5B
  623.  92 '\'  $5C     93 ']'  $5D     94 '^'  $5E     95 '_'  $5F     96 '`'  $60
  624.  97 'a'  $61     98 'b'  $62     99 'c'  $63    100 'd'  $64    101 'e'  $65
  625. 102 'f'  $66    103 'g'  $67    104 'h'  $68    105 'i'  $69    106 'j'  $6A
  626. 107 'k'  $6B    108 'l'  $6C    109 'm'  $6D    110 'n'  $6E    111 'o'  $6F
  627. 112 'p'  $70    113 'q'  $71    114 'r'  $72    115 's'  $73    116 't'  $74
  628. 117 'u'  $75    118 'v'  $76    119 'w'  $77    120 'x'  $78    121 'y'  $79
  629. 122 'z'  $7A    123 '{'  $7B    124 '|'  $7C    125 '}'  $7D    126 '~'  $7E
  630. 127 ''   $7F    128 'Ä'  $80    129 'Å'  $81    130 'Ç'  $82    131 'É'  $83
  631. 132 'Ñ'  $84    133 'Ö'  $85    134 'Ü'  $86    135 'á'  $87    136 'à'  $88
  632. 137 'â'  $89    138 'ä'  $8A    139 'ã'  $8B    140 'å'  $8C    141 'ç'  $8D
  633. 142 'é'  $8E    143 'è'  $8F    144 'ê'  $90    145 'ë'  $91    146 'í'  $92
  634. 147 'ì'  $93    148 'î'  $94    149 'ï'  $95    150 'ñ'  $96    151 'ó'  $97
  635. 152 'ò'  $98    153 'ô'  $99    154 'ö'  $9A    155 'õ'  $9B    156 'ú'  $9C
  636. 157 'ù'  $9D    158 'û'  $9E    159 'ü'  $9F    160 '†'  $A0    161 '°'  $A1
  637. 162 '¢'  $A2    163 '£'  $A3    164 '§'  $A4    165 '•'  $A5    166 '¶'  $A6
  638. 167 'ß'  $A7    168 '®'  $A8    169 '©'  $A9    170 '™'  $AA    171 '´'  $AB
  639. 172 '¨'  $AC    173 '≠'  $AD    174 'Æ'  $AE    175 'Ø'  $AF    176 '∞'  $B0
  640. 177 '±'  $B1    178 '≤'  $B2    179 '≥'  $B3    180 '¥'  $B4    181 'µ'  $B5
  641. 182 '∂'  $B6    183 '∑'  $B7    184 '∏'  $B8    185 'π'  $B9    186 '∫'  $BA
  642. 187 'ª'  $BB    188 'º'  $BC    189 'Ω'  $BD    190 'æ'  $BE    191 'ø'  $BF
  643. 192 '¿'  $C0    193 '¡'  $C1    194 '¬'  $C2    195 '√'  $C3    196 'ƒ'  $C4
  644. 197 '≈'  $C5    198 'Δ'  $C6    199 '«'  $C7    200 '»'  $C8    201 '…'  $C9
  645. 202 ' '  $CA    203 'À'  $CB    204 'Ã'  $CC    205 'Õ'  $CD    206 'Œ'  $CE
  646. 207 'œ'  $CF    208 '–'  $D0    209 '—'  $D1    210 '“'  $D2    211 '”'  $D3
  647. 212 '‘'  $D4    213 '’'  $D5    214 '÷'  $D6    215 '◊'  $D7    216 'ÿ'  $D8
  648. 217 'Ÿ'  $D9
  649.  
  650.  
  651.  
  652.  
  653. This is no complete manual to MacsBug.  This is taken from a file I wrote a while
  654. back and is meant to be an extension of the file called "Hex and Such".
  655.  
  656.  
  657. --==< The Basics >==--
  658.  
  659.  
  660. You install MacsBug simply by throwing it into the System Folder, and by restarting
  661. your machine.  You activate it by pressing the “command” and “power-key” (the one
  662. towards the top of your keyboard marked with the head of an arrow pointing to the
  663. left) buttons.  This should have “dropped” you into MacsBug.  You will notice that
  664. you are in MacsBug because your desktop is replaced with a with a bunch of numbers on
  665. a white background.
  666. Well, going from the top left side, under “SP” is the current position of the stack
  667. pointer, underneath the position of the SP are the values contained in the SP.
  668. Under those numbers is the name of the application that is currently the foremost
  669. one.
  670. Under that is the status of the Status Register, followed by the info held in the 8
  671. data registers, and the 8 address registers (or the 32 registers if it is a PPC
  672. program).  To the right of the registers is a horizontal line going across the
  673. screen.
  674. Under that are about 4 lines of text.  The topmost line describes where in the
  675. application’s code the processor was halted.  Under that line are 3 other lines with
  676. assembly commands.  These are the three commands in line to be executed.
  677. To the right of them (in the right bottom corner) are the hexadecimal values of the
  678. assembly commands.
  679. Above this section (in the middle) is a large empty space.   This gets filled up with
  680. the results of the commands you give to MacsBug.
  681. Your commands get written under the three assembly commands.
  682.  
  683. What happens when you drop into MacsBug is that your processor stops executing
  684. commands, and you can for example go through a code step by step, command by command,
  685. following through exactly what the program does.  So how do you do that?
  686. Type “t” followed by a return.
  687. This causes the processor to execute the next assembly command in line.  The assembly
  688. command that was executed appears now in the middle blank section of your screen, and
  689. a new assembly command appears under the two old ones.
  690.  
  691.  
  692. --==< Basic MacsBug Commands >==--
  693.  
  694.    - t : traces over the next command in line.  If it is used on a JSR command it
  695. jumps over the the subroutine.  (It executes the whole subroutine, without allowing
  696. you to see what happened)
  697.  
  698.    - s : does the same thing as “t” except it “steps into” a subroutine.  For example
  699. if you are not interested in what happens in an subroutine you should type “t”.  This
  700. causes the processor to continue until it reaches a RTS command, and only then give
  701. the control back to you.  If you on the other hand want to see what happens in that
  702. subroutine, you should type “s” to step into it and follow through the code from
  703. there.
  704.  
  705.    - es : this forces the current application to quit (not always).
  706.  
  707.    - rs :  restarts your computer (sometimes it doesn't work and you have to do it
  708. the old fashioned way: apple-control-powerkey)
  709.  
  710.    - rb :  reboots your computer (boots up the different external devices at
  711. startup).  This is slower then the “rb” command
  712.  
  713.    - dm [address] : displays what is in the memory at a given address.  For example,
  714. the command “dm a6” shows you what is held in the address pointed to by address
  715. register 6.  If you type “dm abcd”  it shows you what is held in the memory at
  716. location “abcd” (in hex that is).
  717.  
  718.    - db [address] : displays byte from address
  719.  
  720.    - dw [address] : displays word from address
  721.  
  722.    - dl [address] : displays long from address
  723.  
  724.    - il : dissembles the codes.  Used if you, for example, want to see what happens
  725. after a branch code.
  726.  
  727.    - atb [a-trap name] : MacsBug activates every time that a-trap is being called.
  728.  
  729.    - atc : clears a-traps
  730.  
  731.    - f address expr ‘string’ : this is the find command.  “address” refers to the
  732. starting point of the search; “expr” is how many bytes it should search; “ ’string' ”
  733. is what you’re looking for!  Observe the semi quotation mark before the string!  You
  734. need to use that!
  735.  
  736. You can find out more about commands for MacsBug by typing “help”
  737.  
  738.  
  739.